﻿#region Copyright (c) 2013-05, Olaf Kober <amarok.projects@gmail.com>
//================================================================================
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//================================================================================
#endregion

using System;
using System.Windows.Controls;


namespace Amarok.Presentation
{
	/// <summary>
	/// This type contains extension methods for simplifying the localization of common controls.
	/// </summary>
	public static class LocalizeHelper
	{
		#region AccessText

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="text">
		/// The text of the control.</param>
		public static void Localize(this AccessText control, String text)
		{
			control.Text = text;
		}

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="text">
		/// The text of the control.</param>
		/// <param name="tooltip">
		/// The tool tip text of the control.</param>
		public static void Localize(this AccessText control, String text, String tooltip)
		{
			control.Text = text;
			control.ToolTip = tooltip;
		}

		#endregion

		#region TextBlock

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="text">
		/// The text of the control.</param>
		public static void Localize(this TextBlock control, String text)
		{
			control.Text = text;
		}

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="text">
		/// The text of the control.</param>
		/// <param name="tooltip">
		/// The tool tip text of the control.</param>
		public static void Localize(this TextBlock control, String text, String tooltip)
		{
			control.Text = text;
			control.ToolTip = tooltip;
		}

		#endregion

		#region ContentControl: Button, CheckBox, Label, etc.

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="content">
		/// The content text of the control.</param>
		public static void Localize(this ContentControl control, String content)
		{
			control.Content = content;
		}

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="content">
		/// The content text of the control.</param>
		/// <param name="tooltip">
		/// The tool tip text of the control.</param>
		public static void Localize(this ContentControl control, String content, String tooltip)
		{
			control.Content = content;
			control.ToolTip = tooltip;
		}

		#endregion

		#region HeaderedContentControl: Expander, GroupBox, TabItem, etc.

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="header">
		/// The header text of the control.</param>
		public static void Localize(this HeaderedContentControl control, String header)
		{
			control.Header = header;
		}

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="header">
		/// The header text of the control.</param>
		/// <param name="tooltip">
		/// The tool tip text of the control.</param>
		public static void Localize(this HeaderedContentControl control, String header, String tooltip)
		{
			control.Header = header;
			control.ToolTip = tooltip;
		}

		#endregion

		#region HeaderedItemsControl: MenuItem, RibbonTab, RibbonGroup, etc.

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="header">
		/// The header text of the control.</param>
		public static void Localize(this HeaderedItemsControl control, String header)
		{
			control.Header = header;
		}

		/// <summary>
		/// This methods helps in applying localized text resources.
		/// </summary>
		/// 
		/// <param name="control">
		/// The control to which localized text resources should be applied.</param>
		/// <param name="header">
		/// The header text of the control.</param>
		/// <param name="tooltip">
		/// The tool tip text of the control.</param>
		public static void Localize(this HeaderedItemsControl control, String header, String tooltip)
		{
			control.Header = header;
			control.ToolTip = tooltip;
		}

		#endregion

	}
}
